def encryption(offset):
    file = open("mayun.txt", "rt", encoding="utf-8")
    context = file.read()

    result = []
    for item in context:
        if item.isupper():
            result += chr((ord(item) + offset - 65) % 26 + 65)
        elif item.islower():
            result += chr((ord(item) + offset - 97) % 26 + 97)
        else:
            result += item

    file.close()
    print("".join(result))


def offset():
    word = input("")
    ascii_sum = 0

    for item in word:
        ascii_sum += ord(item)
    offset_value = ascii_sum % 26
    print(offset_value)
    return offset_value


def words_statistics():

    file = open("mayun.txt", "rt", encoding="utf-8")
    context = file.read()
    context = context.replace("，", " ")
    context = context.replace(",", " ")
    context = context.replace(".", " ")
    while "  " in context:
        context = context.replace("  ", " ")

    words = context.split(" ")

    print(f"{len(words)-1} words in all")
    file.close()


def character_statistics():
    capital = 0
    lowercase = 0
    number = 0
    space = 0
    other_char = 0

    file = open("mayun.txt", "rt", encoding="utf-8")
    context = file.read()
    for item in context:
        if 65 <= ord(item) <= 90:
            capital += 1
        elif 97 <= ord(item) <= 122:
            lowercase += 1
        elif 48 <= ord(item) <= 57:
            number += 1
        elif item.isspace():
            space += 1
        else:
            other_char += 1
    print(f"{capital} {lowercase} {number} {space} {other_char}")
    file.close()


if __name__ == "__main__":

    character_statistics()
    words_statistics()
    offset_value = offset()
    encryption(offset_value)
